﻿

using IotClientService.Models.Hbc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IotClientService.Distincts;
/// <summary>
/// readword比较器
/// </summary>
public class PlcReadWordDistinct : IEqualityComparer<PlcReadWord>
{
    public bool Equals(PlcReadWord? x, PlcReadWord? y)
    {
        if (x == null || y == null) return false;
        if (x.MemoryType == y.MemoryType && x.StartAddr == y.StartAddr && x.DataType == y.DataType && x.ReadCount == y.ReadCount && x.DBBlock == y.DBBlock)
        {
            return true;
        }
        return false;
    }

    public int GetHashCode(PlcReadWord obj)
    {
        return ((int)obj.MemoryType ^ obj.StartAddr ^ (int)obj.DataType ^ obj.ReadCount).GetHashCode();
    }
}
